<?php
namespace App\Http\Controllers;

use App\Models\Hotel;
use App\Models\Hotroom;
use Illuminate\Support\Facades\Schema;

class HotelController extends WxBaseController{
    protected $except=['index','show','getRooms'];
    public function index(){
        $hotels = Hotel::orderBy('recommended','desc')->get();
        editImageUrl($hotels);
        return $this->apiReturn(true,'success',$hotels);
    }
    public function show($id){
        $hotel = Hotel::where('id',$id);
        //更新浏览量
        if(Schema::hasColumn('hotels', 'watch')){
            $hotel->increment('watch');
        };
        $arr= $hotel->get();
        editImageUrl($arr);
        return $this->apiReturn(true,'success',$arr);
    }
    public function getRooms($id){
        $rooms = Hotroom::where('hotel_id',$id)->get();
        editImageUrl($rooms);
        return $this->apiReturn(true,'success',$rooms);
    }

}